define(['jquery', 'bootstrap', 'userend', 'table', 'form'], function ($, undefined, Userend, Table, Form) {

    var Controller = {
        index: function () {
            Controller.api.bindevent();
            $(document).on("click", ".btn-markone", function () {
                var that = this;
                Fast.api.ajax({
                    data: {act: "mark", notification_id: $(that).data("id")}
                }, function (data, ret) {
                    $(that).text("已读").removeClass("btn-markone").addClass("disabled");
                    return false;
                });
            });
            $(document).on("click", ".btn-mark", function () {
                var that = this;
                var markone = $(that).closest(".media").find(".btn-markone");
                if (markone.size() > 0) {
                    Fast.api.ajax({
                        data: {act: "mark", notification_id: $(that).data("id")}
                    }, function (data, ret) {
                        markone.text("已读").removeClass("btn-markone").addClass("disabled");
                        location.href = $(that).attr("href");
                        return false;
                    });
                    return false;
                }
            });
            $(document).on("click", ".btn-delone", function () {
                var that = this;
                Fast.api.ajax({
                    data: {act: "del", notification_id: $(that).data("id")}
                }, function (data, ret) {
                    $(that).closest(".comment").slideUp();
                });
            });
            $(document).on("click", ".btn-markall", function () {
                var that = this;
                Fast.api.ajax({
                    data: {act: "markall"}
                }, function (data, ret) {
                    $(".btn-markone").text("已读").removeClass("btn-markone").addClass("disabled");
                });
            });
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});